Public Class CProductCode
    Inherits BOBase

    Protected m_State As ProductCodeDS
    Protected m_DA As ProductCodes

#Region "   Inherits Implementation"
    Sub New()
        m_State = New ProductCodeDS
        m_DA = New ProductCodes
    End Sub

    Public Overrides ReadOnly Property DA() As DABase
        Get
            If m_DA Is Nothing Then
                m_DA = New ProductCodes
            End If

            Return m_DA
        End Get
    End Property

    Public Overrides Property ObjectState() As DataSet
        Get
            Return m_State
        End Get
        Set(ByVal Value As DataSet)
            Try
                m_State = CType(Value, ProductCodeDS)
            Catch ex As InvalidCastException
                Throw New ApplicationException("Invalid ProductCode Dataset!", ex)
            End Try
        End Set
    End Property

    Public Overrides Sub Init()
        Dim dr As ProductCodeDS.PRODUCT_CODERow = m_State.PRODUCT_CODE.NewPRODUCT_CODERow
        With dr
            .CODE = ""
            .DESCRIPTION = ""
            .PART_OF_BARCODE = ""
            .CUSTOMER_ID_FK = 0
        End With
        m_State.PRODUCT_CODE.Rows.Add(dr)
    End Sub
#End Region

#Region "   Data Properties"
    Protected ReadOnly Property DataRow() As ProductCodeDS.PRODUCT_CODERow
        Get
            Return CType(Me.Row, ProductCodeDS.PRODUCT_CODERow)
        End Get
    End Property

    Public ReadOnly Property ID() As System.Int32
        Get
            Return Me.DataRow.PRODUCT_CODE_ID_PK
        End Get
    End Property

    Public Property CustomerID() As System.Int32
        Get
            Return Me.DataRow.CUSTOMER_ID_FK
        End Get
        Set(ByVal Value As System.Int32)
            Me.DataRow.CUSTOMER_ID_FK = Value
        End Set
    End Property

    Public Property Code() As String
        Get
            Return Me.DataRow.CODE
        End Get
        Set(ByVal Value As String)
            Me.DataRow.CODE = Value
        End Set
    End Property

    Public Property Description() As String
        Get
            Return Me.DataRow.DESCRIPTION
        End Get
        Set(ByVal Value As String)
            Me.DataRow.DESCRIPTION = Value
        End Set
    End Property

    Public Property PartOfBarcode() As String
        Get
            Return Me.DataRow.PART_OF_BARCODE
        End Get
        Set(ByVal Value As String)
            Me.DataRow.PART_OF_BARCODE = Value
        End Set
    End Property
#End Region


#Region "Listing function"

    Public Shared Function GetProductCodeList(ByVal customerID As Integer) As DataSet
        Return DataHelper.ExecuteDataSet2("GetProductCodeList", customerID)
    End Function

#End Region

End Class
